home *** CD-ROM | disk | FTP | other *** search
/ C# & Game Programming - A…er's Guide (2nd Edition) / Buono 2nd Ed.iso / Chapter2 / 2.8 / 2.8.cs next >
Encoding:
Text File  |  2004-08-31  |  1.1 KB  |  28 lines

  1. /* Compound if and else-if statements. */
  2. using System;
  3.  
  4. namespace Chapter2 {
  5.     class Class1 {
  6.         static void Main() {
  7.             string input;
  8.             float MyNumber;                
  9.             
  10.             Console.Write("How old are you? "); 
  11.             input = Console.ReadLine();
  12.             MyNumber = float.Parse(input);                                                                         
  13.     
  14.             if (MyNumber >= 18)           
  15.                 Console.WriteLine("You're an adult\n" + "You can vote\n");             
  16.             else if (MyNumber == 17)                                
  17.                 Console.WriteLine("Your turn will come \n");   
  18.             else if (MyNumber == 16) { // compound statement 
  19.                 Console.Write("\n Don't rush it boy you'll only be young once\n"
  20.                     + "How old are you again? ");
  21.                 input = Console.ReadLine();
  22.                 MyNumber = float.Parse(input);
  23.             } else 
  24.                 Console.WriteLine("\n You're just too young!!!\n");
  25.         }
  26.     }
  27. }   
  28.